package com.example.week07.service.impl;

import com.example.week07.dao.mapper.UserMapper;
import com.example.week07.dao.model.User;
import com.example.week07.service.IUserService;
import com.example.week07.utils.IdGenerateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 西柚
 */
@Component
@Transactional(rollbackFor = Exception.class)
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 新增用户
     *
     * @param user
     */
    @Override
    public void add(User user) {
        userMapper.insert(user);
    }

    /**
     * 批量新增用户
     *
     * @param userList
     */
    @Override
    public void batchAdd(List<User> userList) {
        userMapper.batchInsert(userList);
    }

}
